<template>
	<view class='container bg-w'>
		<view class="header uni-flex uni-row flex-between">
			<uni-nav-bar title="维护上报">
				<template slot='left'>
					<view class="flex width-100">
						<i class='iconfont iconfanhui' @click='goBack()'></i>
					</view>
				</template>
			</uni-nav-bar>
		</view>
		<view class="position-r-top">
			<view class="buildList" v-if="productData.length > 0">
				<uni-list>
				    <uni-list-item v-for="(item,index) in productData" :key="index" showArrow link :to="'/pages/Application/MaintainReport/MaintainProject/MaintainProject?maintainTaskId='+item.maintainTaskId">
						<template slot='body'>
							<view class="main-center">
								<view class="buildList-body">
									<view class="color-6 flex algin-i-c"> <view>{{item.taskName}}</view></view>
									<view class="color-af flex algin-i-c"> <text class="wid-80 txtCut1">{{item.planCompleteTime}}</text></view>
								</view>
								<view>
									<text v-if="item.status===0 && item.statusDesc!='已逾期'">立即维护</text>
									<text v-if="item.status===1 && item.statusDesc!='已逾期'">继续维护</text>
									<text v-if="item.statusDesc==='已逾期'" :class="item.statusDesc==='已逾期'?'color-red':''">已逾期</text>
								</view>
							</view>
						</template>
					</uni-list-item>
				</uni-list>
			</view>
			<view class="nodata" v-else>
				<text>暂无数据</text>
			</view>
		</view>
	</view>
</template>

<script>
	import { pageProject } from '@/common/api/MaintainReport.js'
	export default {
		data() {
			return {
				productData: [],
				page: {
					pageNo: 1,
					pageSize: 20,
				},
				totalPage:0,
				periodList:[],
				type:2,
			}
		},
		onShow() {
			this.loadProductList();
		},
		methods: {
			loadProductList(){
				this.productData=[]
				pageProject(this.page).then(res => {
					if(res.code == 20000){
						if(res.data){
							this.totalPage = res.data.pages;
							this.productData = this.productData.concat(res.data.records)
						}
					}
				})
			},
			onReachBottom() { //上拉加载更多
				this.page.pageNo++
				if (this.page.pageNo <= this.totalPage) {
					this.loadProductList();
				}
			},
			onPullDownRefresh(){//下拉刷新
				this.page.pageNo = 1;
				this.productData = [];
				this.loadProductList();
				setTimeout(function () {
						uni.stopPullDownRefresh();
				}, 1000);
			},
		}
	}
</script>

<style lang="less" scoped>
	.buildList{
		.main-center{
			width: 100%;
			display: flex;
			align-items: center;
		}
		.buildList-body{
			width: 84%;
			>view:first-child{
				margin-bottom: 20rpx;
			}
			>view{
				> view{
					min-width: 160rpx;
				}
			}
			>uni-view:first-child{
				margin-bottom: 0 !important;
			}
		}
	}
</style>
